<?php		
/**
 * 注：此模板为自动生成模板，需要根据实际情况调整修改
 * 此模板对 无主键/单一主键 表的支持较好，联合主键表在下一版本开发
 */					
class Step_mng_group_mst {
			
		    //数组	
			private $array;
			
					
			public function Step_mng_group_mst($array){	
									  
						$this->array = $array;
				
						 self::setDefault();
				
			   }
		   
		   	
			private function setDefault(){
				
						 if(count($this->array)==0){
				self::setGroupid("");
					self::setGroupname("");
					self::setImg("");
					self::setDisplayorder("");
					self::setState("");
					self::setCreatedate("");
					self::setUpdatedate("");
					
							}
					}
				
			
		   				
			
					
				
			public function setGroupid($value) {
			       $this->array = array_merge ($this->array,array(
			       'GROUPID' => $value));
		     	} 
			public function getGroupid(){							
			      return $this->array ['GROUPID'];
	            } 
					
				
			public function setGroupname($value) {
			       $this->array = array_merge ($this->array,array(
			       'GROUPNAME' => $value));
		     	} 
			public function getGroupname(){							
			      return $this->array ['GROUPNAME'];
	            } 
					
				
			public function setImg($value) {
			       $this->array = array_merge ($this->array,array(
			       'IMG' => $value));
		     	} 
			public function getImg(){							
			      return $this->array ['IMG'];
	            } 
					
				
			public function setDisplayorder($value) {
			       $this->array = array_merge ($this->array,array(
			       'DISPLAYORDER' => $value));
		     	} 
			public function getDisplayorder(){							
			      return $this->array ['DISPLAYORDER'];
	            } 
					
				
			public function setState($value) {
			       $this->array = array_merge ($this->array,array(
			       'STATE' => $value));
		     	} 
			public function getState(){							
			      return $this->array ['STATE'];
	            } 
					
				
			public function setCreatedate($value) {
			       $this->array = array_merge ($this->array,array(
			       'CREATEDATE' => $value));
		     	} 
			public function getCreatedate(){							
			      return $this->array ['CREATEDATE'];
	            } 
					
				
			public function setUpdatedate($value) {
			       $this->array = array_merge ($this->array,array(
			       'UPDATEDATE' => $value));
		     	} 
			public function getUpdatedate(){							
			      return $this->array ['UPDATEDATE'];
	            } 
		
			
			public function toInsertCSV() {
						 $str="";
				
						// groupid
						$str .= "'". self::getGroupid()."',";
						// groupname
						$str .= "'". self::getGroupname()."',";
						// img
						$str .= "'". self::getImg()."',";
						// displayorder
						$str .= "'". self::getDisplayorder()."',";
						// state
						$str .= "'". self::getState()."',";
						// createdate
						$str .= "now()" . ",";
						
						// updatedate
						$str .= "now()";
						return $str;
						}
				
		
			
			public function toUpdateSet() {
						 $str="";
				
						// groupname
						$str.= 'GROUPNAME = "' . self::getGroupname() . '",';
						
						// img
						$str.= 'IMG = "' . self::getImg() . '",';
						
						// displayorder
						$str.= 'DISPLAYORDER = "' . self::getDisplayorder() . '",';
						
						// state
						$str.= 'STATE = "' . self::getState() . '",';
						
						// updatedate
						$str .= "UPDATEDATE = now()";
						return $str;
			    }
				
		
			
			public function toUpdateWhere(){
						 $str = ""; 
						$str .= "GROUPID = '" . self::getGroupid()."'";
						 return $str;
		        }
		
}		
									
  	
class Step_mng_group_mst_DAO {	
									
						private static $TABLENAME = 'STEP_MNG_GROUP_MST';
								
								
			
			
				public static function getRecord($id,$dbCon){
						 $where = "GROUPID = '$id'";
								 $record = SearchDb::getRecord
								 ($dbCon,static::$TABLENAME,$where);
								 if($record != null){
								 return new Step_mng_group_mst($record);
				      		}
				      		 return null;
				      		 }
		
			
			
				public static function getList($dbCon) {
						 $where = "";
						 $list = SearchDb::getList($dbCon,static::$TABLENAME,$where);
						 $results = array();
						 
						foreach($list as $record){
						 array_push ( $results, new Step_mng_group_mst($record));
								}
								 return $results;
	               }

			
			
			   public static function getRecordMem($id,$mstCon,$memCon) {
						 
						$listAll = self::getListMem ( $mstCon,$memCon);
						 
						foreach($listAll as $record) {
						
						if($record->getGroupid() == $id){
								
								return $record;
								
								}
								}
								 return null;
								}

			
			
			   public static function getListMem($mstCon,$memCon){
						 
						$listAll = SearchDb::getListMem($mstCon,$memCon,static::$TABLENAME);
						 
						$results = array();
						 
						foreach($listAll as $record){
						 array_push ( $results,new Step_mng_group_mst($record));
								 
					}
								 return $results; 
								 }

			
			
			   public static function insert($record,$dbCon){
				
						try {
					
								$id = $record->getGroupid();
								$oldrecord = self::getRecord($id,$dbCon);
								if($oldrecord != null) {
								   throw new Exception ("重复插入");
								}
								ChangeDb::insert($dbCon,static::$TABLENAME,$record);
							} catch(Exception $e){
								throw $e;
								}
						}

			
			
			   public static function update($record ,$dbCon){
						try{
								$id = $record->getGroupid();
								$oldrecord = self::getRecord($id,$dbCon);
								if($oldrecord == null){
										throw new Exception("不存在该记录");
								}
								ChangeDb::update($dbCon,static::$TABLENAME,$record);
						} catch(Exception $e){
										throw $e;
									}
					 }

			
			
			   public static function delete ($record,$dbCon){
						try{
							$id = $record->getGroupid();
							$oldrecord = self::getRecord($id,$dbCon);
							if($oldrecord == null){
									throw new Exception("不存在该记录");
							}
							ChangeDb::delete($dbCon,static::$TABLENAME,$record);
						} catch(Exception $e){
									throw $e;
				        	}
					}
}
										 
?>